Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind out CRC64 #662

Merged
merged 7 commits into from
Sep 13, 2024
Merged

Bind out CRC64 #662

merged 7 commits into from
Sep 13, 2024

Conversation

DmitriyMusatkin
Copy link
Contributor

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor

@graebm graebm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix & ship

source/checksum/CRC.cpp Outdated Show resolved Hide resolved
* Selects a suitable implementation based on hardware capabilities.
* Pass previousCRC32 if updating a running checksum.
*/
uint32_t AWS_CRT_CPP_API ComputeCRC32(const ByteCursor &input, uint32_t previousCRC32 = 0) noexcept;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial: pass trivial view-types by value

Suggested change
uint32_t AWS_CRT_CPP_API ComputeCRC32(const ByteCursor &input, uint32_t previousCRC32 = 0) noexcept;
uint32_t AWS_CRT_CPP_API ComputeCRC32(ByteCursor input, uint32_t previousCRC32 = 0) noexcept;

This stackoverflow post agrees

And we've had lots of annoying C code where a byte-cursor was passed by pointer, so you need to make a tmp before calling that function, like:

struct aws_byte_cursor tmp = aws_byte_cursor_from_buf(data_as_buf); // ugh
aws_compute_crc32(&tmp, 0);

vastly better to pass by value

aws_compute_crc32(aws_byte_cursor_from_buf(data_as_buf), 0);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. blindly copied hash interface here without thinking too much

@DmitriyMusatkin DmitriyMusatkin merged commit 260575a into main Sep 13, 2024
59 checks passed
@DmitriyMusatkin DmitriyMusatkin restored the crc64 branch October 30, 2024 20:42
@DmitriyMusatkin DmitriyMusatkin deleted the crc64 branch October 30, 2024 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants